'use strict';

module.exports = {
  up: async (queryInterface, Sequelize) => {
    /**
     * Add altering commands here.
     *
     * Example:
     * await queryInterface.createTable('users', { id: Sequelize.INTEGER });
     */
    const { INTEGER, STRING, DATE } = Sequelize;
    await queryInterface.createTable("sys_menu", {
      menu_id: {
        type: INTEGER(20),
        comment: "菜单ID",
        allowNull: false,
        primaryKey: true,
        autoIncrement: true
      },
      menu_name:{
        type:STRING(50),
        comment:"菜单名称",
        allowNull:false,
      },
      parent_id:{
        type:INTEGER(20),
        comment:"父菜单ID",
        defaultValue:0
      },
      order_num:{
        type:INTEGER(4),
        comment:"显示顺序",
        defaultValue:0
      },
      path:{
        type:STRING(200),
        comment:"路由地址"
      },
      component:{
        type:STRING,
        comment:"组件路径"
      },
      is_frame:{
        type:STRING(1),
        comment:"是否为外链（0是 1否）",
        defaultValue:"1"
      },
      is_cache:{
        type:STRING(1),
        comment:"是否缓存（0缓存 1不缓存）",
        defaultValue:"0"
      },

      menu_type:{
        type:STRING(1),
        comment:"菜单类型（M目录 C菜单 F按钮）",
        defaultValue:""
      },
      visible:{
        type:STRING(1),
        comment:"菜单状态（0显示 1隐藏）",
        defaultValue:"0"
      },
      status:{
        type:STRING(1),
        comment:"菜单状态（0正常 1停用）",
        defaultValue:"0"
      },
      perms:{
        type:STRING(100),
        comment:"权限标识"
      },
      icon:{
        type:STRING(100),
        comment:"菜单图标",
        defaultValue:""
      },
      create_by:{
        type:STRING(64),
        comment:"创建者",
        defaultValue:""
      },
      update_by:{
        type:STRING(64),
        comment:"更新者",
        defaultValue:""
      },
      remark:{
        type:STRING(500),
        comment:"备注",
        defaultValue:""
      },
      created_at:{
        type:DATE,
        comment:"创建时间",
      },
      updated_at:{
        type:DATE,
        comment:"更新时间",
      },
      deleted_at:{
        type:DATE,
        comment:"删除时间",
      }
    })
  },

  down: async (queryInterface, Sequelize) => {
    /**
     * Add reverting commands here.
     *
     * Example:
     * await queryInterface.dropTable('users');
     */
    await queryInterface.dropTable('sys_menu');
  }
};
